package com.tm.pojo;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.util.BasePojo;
import com.util.SysCache;

/**
 * Task entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "task")
public class Task extends BasePojo implements java.io.Serializable {

	// Fields

	private String			taskName;
	private String			taskDesc;
	private String			fixBranch;
	private Integer		priority;
	private String			assignedTo;
	private Float			estimateHour;
	private Timestamp	estimateStartTime;
	private Timestamp	estimateEndTime;
	private Float			actureHourWorked;
	private Timestamp	actureStartTime;
	private Timestamp	actureEndTime;
	private Timestamp	deadLine;
	private Integer		blockedBy;
	private Integer		parentTask;
	private String			status;
	private Boolean		isActive;
	private String			comment;

	// Constructors

	/** default constructor */
	public Task() {
		super();
		this.init();
	}

	public Task(String taskName) {
		super();
		this.taskName = taskName;
		this.init();
	}




	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "task_name", nullable = false)
	public String getTaskName() {
		return this.taskName;
	}

	public void setTaskName(String taskName) {
		if(taskName != null){
			taskName = taskName.trim();
		}
		this.taskName = taskName;
	}

	@Column(name = "task_desc")
	public String getTaskDesc() {
		return this.taskDesc;
	}

	public void setTaskDesc(String taskDesc) {
		this.taskDesc = taskDesc;
	}

	@Column(name = "fix_branch", nullable = false, length = 50)
	public String getFixBranch() {
		return this.fixBranch;
	}

	public void setFixBranch(String fixBranch) {
		this.fixBranch = fixBranch;
	}

	@Column(name = "priority", nullable = false)
	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@Column(name = "assigned_to", length = 50)
	public String getAssignedTo() {
		return this.assignedTo;
	}

	public void setAssignedTo(String assignedTo) {
		this.assignedTo = assignedTo;
	}

	@Column(name = "estimate_hour", precision = 12, scale = 0)
	public Float getEstimateHour() {
		return this.estimateHour;
	}

	public void setEstimateHour(Float estimateHour) {
		this.estimateHour = estimateHour;
	}

	@Column(name = "estimate_start_time", length = 19)
	public Timestamp getEstimateStartTime() {
		return this.estimateStartTime;
	}

	public void setEstimateStartTime(Timestamp estimateStartTime) {
		this.estimateStartTime = estimateStartTime;
	}

	@Column(name = "estimate_end_time", length = 19)
	public Timestamp getEstimateEndTime() {
		return this.estimateEndTime;
	}

	public void setEstimateEndTime(Timestamp estimateEndTime) {
		this.estimateEndTime = estimateEndTime;
	}

	@Column(name = "acture_hour_worked", precision = 12, scale = 0)
	public Float getActureHourWorked() {
		return this.actureHourWorked;
	}

	public void setActureHourWorked(Float actureHourWorked) {
		this.actureHourWorked = actureHourWorked;
	}

	@Column(name = "acture_start_time", length = 19)
	public Timestamp getActureStartTime() {
		return this.actureStartTime;
	}

	public void setActureStartTime(Timestamp actureStartTime) {
		this.actureStartTime = actureStartTime;
	}

	@Column(name = "acture_end_time", length = 19)
	public Timestamp getActureEndTime() {
		return this.actureEndTime;
	}

	public void setActureEndTime(Timestamp actureEndTime) {
		this.actureEndTime = actureEndTime;
	}

	@Column(name = "dead_line", length = 19)
	public Timestamp getDeadLine() {
		return this.deadLine;
	}

	public void setDeadLine(Timestamp deadLine) {
		this.deadLine = deadLine;
	}

	@Column(name = "blocked_by")
	public Integer getBlockedBy() {
		return this.blockedBy;
	}

	public void setBlockedBy(Integer blockedBy) {
		this.blockedBy = blockedBy;
	}

	@Column(name = "parent_task")
	public Integer getParentTask() {
		return this.parentTask;
	}

	public void setParentTask(Integer parentTask) {
		this.parentTask = parentTask;
	}

	@Column(name = "status", nullable = false, length = 50)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "is_active", nullable = false)
	public Boolean getIsActive() {
		return this.isActive;
	}

	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}

	@Column(name = "comment")
	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	@Column(name = "created_time", nullable = false, length = 19)
	public Timestamp getCreatedTime() {
		return this.createdTime;
	}

	public void setCreatedTime(Timestamp createdTime) {
		this.createdTime = createdTime;
	}

	@Column(name = "latest_modify", length = 19)
	public Timestamp getLatestModify() {
		return this.latestModify;
	}

	public void setLatestModify(Timestamp latestModify) {
		this.latestModify = latestModify;
	}

	@Column(name = "deleted", nullable = false)
	public Boolean getDeleted() {
		return this.deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	@Override
	public BasePojo copyFrom(BasePojo pojo) {
		return null;
	}
	
	/**
	 * 初始化task
	 * @author Michael,Apr 5, 2013
	 */
	public void init(){
		if(this.getAssignedTo() == null){
			this.setAssignedTo(SysCache.getInstance().getSysConfig("default.task.assigned"));
		}
		if(this.getFixBranch() == null){
			this.setFixBranch(SysCache.getInstance().getSysConfig("default.task.branch"));
		}
		if(this.getStatus() == null){
			this.setStatus(SysCache.getInstance().getSysConfig("default.task.status"));
		}
		if(this.getPriority() == null){
			this.setPriority(Integer.parseInt(SysCache.getInstance().getSysConfig("default.task.priority")));
		}
		if(this.getIsActive() == null){
			this.setIsActive(true);
		}
	}

}